package com.blacktry.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blacktry.entity.model.Admin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blacktry.entity.model.Vo.UserVo;
import com.blacktry.entity.model.request.UserRequest;
import com.blacktry.entity.model.vueVO.Option;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author blackTry
 * @since 2021-06-23
 */
public interface AdminMapper extends BaseMapper<Admin> {

    @Select("SELECT admin.id,admin.username,admin.name,admin.affiliation,name_zh FROM admin,role,admin_role where admin.id = admin_role.admin_id\n" +
            "and admin_role.role_id = role.id and role.name_zh = #{role}")
    Page<UserVo> selectRole(String role,Page<UserVo> page);

    @Select("select DISTINCT affiliation from admin")
    String[] selectAllAffiliation();

    @Select("SELECT concat(admin.affiliation,'-',admin.`name`) as label,admin.username as value from admin,admin_role,role where admin.id = admin_role.admin_id and admin_role.role_id = role.id and role.name_zh = '教师'")
    List<Option> selectAllTeacher();
}
